import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.atn.ParserATNSimulator;
import org.antlr.v4.runtime.atn.PredictionContextCache;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.tree.ParseTree;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import static org.antlr.v4.runtime.CharStreams.fromFileName;

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
    public static void main(String[] args) throws Exception{
        try {
            String source = "C:\\Users\\HaiMi\\Desktop\\stil\\STM32F1_Low_Med_density_value_LQFP4_4\\STM32F1_Low_Med_density_value_LQFP4_4_BSCAN_Bypass.stil";
            CharStream input = fromFileName(source);
            STIL_CompilerLexer lexer = new STIL_CompilerLexer(input);
            CommonTokenStream tokenStream = new CommonTokenStream(lexer);
            STIL_CompilerParser parser = new STIL_CompilerParser(tokenStream);

            //解决内存泄露问题
            DFA[] decisionToDFA = parser.getInterpreter().decisionToDFA;
            parser.setInterpreter(new ParserATNSimulator(parser,parser.getATN(),decisionToDFA,new PredictionContextCache()));
            STIL_CompilerParser.Stil_complierContext tree = parser.stil_complier();
            //STIL_CompilerParser.STIL_CompilerContext tree = parser.STIL_Compiler();

        }catch (IOException e){
            e.printStackTrace();
        }
    }
}